import { BasicColumn, FormProps, FormSchema } from '/@/components/Table';
import { id, revision } from '/@/model/commonData';
import { CREATOR_NAME, CREATED_TIME, SEARCH_ITEM_COL_PROP } from '/@/constant';
import { AVATAR, USERNAME, EMAIL, GENDER } from '/@/constant/userConstant';

export const columns: BasicColumn[] = [
  {
    title: AVATAR,
    dataIndex: 'avatar',
  },
  {
    title: USERNAME,
    dataIndex: 'username',
  },
  {
    title: GENDER,
    dataIndex: 'gender',
  },
  {
    title: EMAIL,
    dataIndex: 'email',
  },
  {
    title: CREATOR_NAME,
    dataIndex: 'creatorName',
  },
  {
    title: CREATED_TIME,
    dataIndex: 'createdTime',
  },
];

export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    schemas: [
      {
        field: 'username',
        label: USERNAME,
        component: 'Input',
        componentProps: {},
        ...SEARCH_ITEM_COL_PROP,
      },
      {
        field: 'email',
        label: EMAIL,
        component: 'Input',
        componentProps: {},
        ...SEARCH_ITEM_COL_PROP,
      },
    ],
  };
}

export const formSchemas: FormSchema[] = [
  {
    field: 'username',
    component: 'Input',
    label: USERNAME,
    required: true,
    componentProps: {
      placeholder: '用户名',
    },
  },
  {
    field: 'gender',
    component: 'RadioButtonGroup',
    label: GENDER,
    defaultValue: 'MALE',
    componentProps: {
      options: [
        { label: '男', value: 'MALE' },
        { label: '女', value: 'FEMALE' },
      ],
    },
  },
  {
    field: 'email',
    component: 'Input',
    label: EMAIL,
    componentProps: {
      placeholder: EMAIL,
    },
  },
  revision,
  id,
];
